const CompressionWebpackPlugin = require('compression-webpack-plugin');

module.exports = {
  "pages": {
    "index": {
      "entry": process.env.ENTRY_INDEX||'./src/main.js',
      "title": process.env.ENTRY_INDEX_TITLE||'ELCube企业级快速开发模型',
      "icon" : process.env.ENTRY_INDEX_ICON||'elcube_ico.png',
    }
  },
  "runtimeCompiler":false,
  "productionSourceMap":false,
  "css":{
    "loaderOptions":{
      "less":{
        "javascriptEnabled":true
      }
    }
  },
  "devServer": {
    "port": "7200",
    "proxy": {
      "^/api": {
        "target": process.env.DEV_SERVER_PROXY_TARGET,
        "ws": true,
        "changeOrigin": true,
        "pathRewrite":{
          "^/api": process.env.DEV_SERVER_PROXY_PATH
        }
      }
    },
      client: {
          overlay: false
      },
  },
  chainWebpack: config => {
    config.module
        .rule("i18n")
        .resourceQuery(/blockType=i18n/)
        .type('javascript/auto')
        .use("i18n")
        .loader("@kazupon/vue-i18n-loader")
        .end();
  },
  configureWebpack: (config)=>{
    config.plugins.push(
        new CompressionWebpackPlugin({
          test: /\.js$|\.html$|\.css/, //匹配文件名
          threshold: 10240, //对超过10k的数据进行压缩
          deleteOriginalAssets: false //是否删除原文件
        })
    );
  }
}
